package com.awakening.code.job;

import org.quartz.*;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author:这个程序员有纹身
 * @Date: Created in 15:23 2018\1\10 0010
 */
public class HelloJob implements Job{
   /* private String arg1;
    private Float aFloat1;
    private Double aDouble1;

    public String getArg1() {
        return arg1;
    }

    public void setArg1(String arg1) {
        this.arg1 = arg1;
    }

    public Float getaFloat1() {
        return aFloat1;
    }

    public void setaFloat1(Float aFloat1) {
        this.aFloat1 = aFloat1;
    }

    public Double getaDouble1() {
        return aDouble1;
    }

    public void setaDouble1(Double aDouble1) {
        this.aDouble1 = aDouble1;
    }*/

    //类似Timer下的run方法
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //打印当前的执行时间，格式为2017-01-01 00:00:00
        Date date = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("Current Exec Time Is : " + sf.format(date));
        System.out.println("hello");
        //编写具体的业务逻辑
        /*JobKey key = jobExecutionContext.getJobDetail().getKey();
        System.out.println("My Job name and group are:" + key.getName() + ":" + key.getGroup());
        TriggerKey trkey = jobExecutionContext.getTrigger().getKey();
        System.out.println("My Trigger name and group are:" + trkey.getName() + ":" + trkey.getGroup());

        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        JobDataMap tdataMap = jobExecutionContext.getTrigger().getJobDataMap();

        //等于以上两者结合，合并后的dataMap,这里当key相同就会覆盖到（Trigger——>Job）剩下一个标签
        JobDataMap MergedDataMap = jobExecutionContext.getMergedJobDataMap();

        String jobMsg = jobDataMap.getString("message");
        Float jobFloatValue = jobDataMap.getFloat("FloatMathJobValue");

        System.out.println("Job Msg and float:"+jobMsg +"::" +jobFloatValue);

        String trMsg = tdataMap.getString("message");
        Double TrDoubleValue = tdataMap.getDouble("DoubleTriggerValue");
        System.out.println("Trigger Msg and double:"+trMsg +"::" +TrDoubleValue);*/

        /*Trigger currentTrigger = jobExecutionContext.getTrigger();
        System.out.println("Start Time :" + sf.format(currentTrigger.getStartTime()));
        System.out.println("End Time :" + sf.format(currentTrigger.getEndTime()));
        JobKey jobKey = currentTrigger.getJobKey();
        System.out.println("JobKey info--"+"JobName:" +jobKey.getName()+":"+jobKey.getGroup());*/


    }
}
